package com.jrtc.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.jrtc.base.entity.bo.PrescriptionLabelTwo;
import com.jrtc.dao.PrescriptionLabelTwoDao;
import com.jrtc.service.PrescriptionLabelTwoService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 运动处方标签二级分类(PrescriptionLabelTwo)表服务实现类
 *
 * @author makejava
 * @since 2022-09-08 13:36:24
 */
@Service("prescriptionLabelTwoService")
public class PrescriptionLabelTwoServiceImpl implements PrescriptionLabelTwoService
{
    @Resource
    private PrescriptionLabelTwoDao prescriptionLabelTwoDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public PrescriptionLabelTwo queryById(Integer id) {
        return this.prescriptionLabelTwoDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<PrescriptionLabelTwo> queryAllByLimit(int offset, int limit) {
        return this.prescriptionLabelTwoDao.queryAllByLimit(offset, limit);
    }

    @Override
    public IPage<PrescriptionLabelTwo> queryPrescriptionLabelTwoList(PrescriptionLabelTwo prescriptionLabelTwo)
    {
        com.baomidou.mybatisplus.extension.plugins.pagination.Page<PrescriptionLabelTwo> page = new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(prescriptionLabelTwo.getPageNo(),prescriptionLabelTwo.getPageSize() );
        IPage<PrescriptionLabelTwo> prescriptionLabelTwoPage = this.prescriptionLabelTwoDao.queryPrescriptionLabelTwoList(page, prescriptionLabelTwo);
        return prescriptionLabelTwoPage;
    }
    /**
     * 新增数据
     *
     * @param prescriptionLabelTwo 实例对象
     * @return 实例对象
     */
    @Override
    public PrescriptionLabelTwo insert(PrescriptionLabelTwo prescriptionLabelTwo) {
        this.prescriptionLabelTwoDao.insert(prescriptionLabelTwo);
        return prescriptionLabelTwo;
    }

    /**
     * 修改数据
     *
     * @param prescriptionLabelTwo 实例对象
     * @return 实例对象
     */
    @Override
    public PrescriptionLabelTwo update(PrescriptionLabelTwo prescriptionLabelTwo) {
        this.prescriptionLabelTwoDao.update(prescriptionLabelTwo);
        return this.queryById(prescriptionLabelTwo.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.prescriptionLabelTwoDao.deleteById(id) > 0;
    }
}